package com.bit.cfdi.web.services;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.bit.cfdi.web.dao.ConceptoDAO;
import com.bit.cfdi.web.domain.Concepto;
import com.bit.cfdi.web.domain.ConceptoParte;
import com.bit.cfdi.web.domain.Negocio;
@Service
public class ConceptoService {

	@Autowired private ConceptoDAO conceptoDAO;
	
	public void save(final Concepto concepto) throws DataAccessException {
		conceptoDAO.save(concepto);
	}
	
	public void delete(final Concepto concepto) throws DataAccessException {
		conceptoDAO.delete(concepto);
	}


	public Concepto getById(final Long id)  throws DataAccessException {
		return conceptoDAO.getById(id);
	}

	public List<Concepto> getAll()  throws DataAccessException {
		return conceptoDAO.getAll();
	}

	public Concepto getByName(final String name)  throws DataAccessException {
		return conceptoDAO.getByName(name);
	}
 
	public List<Concepto> getAllfromNegocio(Negocio negocio)  throws DataAccessException {
		return conceptoDAO.getAllfromNegocio(negocio);
	} 
	
	public List<Object[]> getBestClientsInTime(final Concepto concepto, 
			final Calendar initDate, 
			final Calendar finalDate)  throws DataAccessException {
		return conceptoDAO.getBestClientsInTime(concepto, initDate, finalDate);
	} 
	
	public List<ConceptoParte> getAllPartConceptos(Concepto concepto)  throws DataAccessException {
		return conceptoDAO.getAllPartConceptos(concepto);
	}
	
	public List<Concepto> searchConceptByAllFields(final Negocio neg, 
			final String toSearch) throws DataAccessException {
		return conceptoDAO.searchConceptByAllFields(neg, toSearch);
	}

	public List<Concepto> searchByDescUnit(final Negocio neg, 
			final String description, final String unit) throws DataAccessException {
		return conceptoDAO.searchByDescUnit(neg, description, unit);
	}
	
	public List<Object[]> getTotalSalesInTime(
			Concepto concept, Calendar initDate, Calendar finalDate)	throws DataAccessException {
		return conceptoDAO.getTotalSalesInTime(concept, initDate, finalDate);
	}
	
	public List<Object[]> getTotalSalesInTimeByCategory(String category, 
			Concepto concept, Calendar initDate, Calendar finalDate) throws DataAccessException {
		return conceptoDAO.getTotalSalesInTimeByCategory(category,concept, initDate, finalDate);
	}

	public ArrayList<Object> getConceptoByDescripcionLike(
			String descripcionLike, Negocio negocio) throws DataAccessException {
		return conceptoDAO.getListaConceptos(descripcionLike, negocio);
	}
	
	public List<Concepto> getByDescr(
			final Negocio negocio,final String descr) throws DataAccessException {
		return conceptoDAO.getByDescr(negocio, descr);
	}

	public Concepto getByNameNegocio(
			String name, Negocio negocio) throws DataAccessException {
		return conceptoDAO.getByNameNegocio(name, negocio);
	}
}
